package com.zjh.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public Authentication hello(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        DefaultOAuth2User user = (DefaultOAuth2User) authentication.getPrincipal();
        return authentication;
    }
}
